//
// Decompiled by Jadx - 396ms
//
package dg;

import android.text.TextUtils;
import dh.a;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Map;
import kotlin.jvm.internal.i;
import kotlin.text.q;
import okhttp3.ad;
import okhttp3.ae;
import okhttp3.s;
import okhttp3.v;
import okhttp3.x;
import okhttp3.z;

public final class b {
    public x a = new x(new x.a());

    public final void b(String str) throws IOException {
        z.a aVar = new z.a();
        aVar.l(str);
        aVar.j("MKCOL", (ad) null);
        a.a(this.a.a(aVar.g()).execute());
    }

    public final boolean c(String str) throws IOException {
        Boolean bool;
        z.a aVar = new z.a();
        aVar.l(str);
        aVar.h("Depth", "0");
        aVar.j("PROPFIND", (ad) null);
        ae execute = this.a.a(aVar.g()).execute();
        if (!execute.r() && execute.e == 404) {
            bool = Boolean.FALSE;
        } else {
            a.a(execute);
            bool = Boolean.TRUE;
        }
        return bool.booleanValue();
    }

    public final InputStream d(String str) throws IOException {
        Map emptyMap = Collections.emptyMap();
        s.a.getClass();
        i.f(emptyMap, "$this$toHeaders");
        String[] strArr = new String[emptyMap.size() * 2];
        int i = 0;
        for (Map.Entry entry : emptyMap.entrySet()) {
            String str2 = (String) entry.getKey();
            String str3 = (String) entry.getValue();
            if (str2 != null) {
                String obj = q.aa(str2).toString();
                if (str3 != null) {
                    String obj2 = q.aa(str3).toString();
                    s.b.a(obj);
                    s.b.b(obj2, obj);
                    strArr[i] = obj;
                    strArr[i + 1] = obj2;
                    i += 2;
                } else {
                    throw new NullPointerException("null cannot be cast to non-null type kotlin.CharSequence");
                }
            } else {
                throw new NullPointerException("null cannot be cast to non-null type kotlin.CharSequence");
            }
        }
        s sVar = new s(strArr);
        z.a aVar = new z.a();
        aVar.l(str);
        aVar.j("GET", (ad) null);
        aVar.i(sVar);
        ae execute = this.a.a(aVar.g()).execute();
        a.a(execute);
        return execute.h.byteStream();
    }

    public final void e(String str, File file) throws IOException {
        v.c.getClass();
        ad create = ad.create(v.a.b("text/plain"), file);
        s.a aVar = new s.a();
        if (!TextUtils.isEmpty(null)) {
            aVar.b("If", "<" + str + "> (<null>)");
        }
        s e = aVar.e();
        z.a aVar2 = new z.a();
        aVar2.l(str);
        i.f(create, "body");
        aVar2.j("PUT", create);
        aVar2.i(e);
        a.a(this.a.a(aVar2.g()).execute());
    }

    public final void f(String str, String str2) {
        x xVar = this.a;
        xVar.getClass();
        x.a aVar = new x.a(xVar);
        aVar.g = new a(str, str2);
        this.a = new x(aVar);
    }
}
